#include <iostream>
#include <boost/asio.hpp>
#include <boost/log/trivial.hpp>
#include "config.hpp"
#include "connection_manager.hpp"

int main(int argc, char* argv[]) {
    if (argc != 2) {
        std::cerr << "Usage: " << argv[0] << " <config_file>" << std::endl;
        return 1;
    }

    try {
        boost::asio::io_context io_context;
        net_channel::client::Config config(argv[1]);
        net_channel::client::ConnectionManager connection_manager(io_context);

        for (const auto& service : config.get_services()) {
            connection_manager.start_service(service);
        }

        BOOST_LOG_TRIVIAL(info) << "Client started";
        io_context.run();
    } catch (const std::exception& e) {
        BOOST_LOG_TRIVIAL(error) << "Client error: " << e.what();
        return 1;
    }

    return 0;
}